# ***meta charset="UTF-8"***
# @Time: 2021/2/2 14:02
# @Author: 邢光强
# @Email： 1062584918@qq.com
# @File： base_page.py
# @Project: crm_project


from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from pages.base_page import BasePage


class PersonalData(BasePage):
    file_upload_locator = (By.ID,"file_upload")
    username_locator = (By.NAME,"name")
    password_locator = (By.ID,"password")
    category_locator = (By.XPATH,"/html/body/div[5]/div[2]/div[2]/form/table/tbody/tr[6]/td[2]/select")
    status_locator = (By.NAME,"status")
    department_locator = (By.ID,"department")
    role_locator = (By.ID,"role")
    sex_locator = (By.XPATH,"/html/body/div[5]/div[2]/div[2]/form/table/tbody/tr[10]/td[2]/input[1]")
    email_locator = (By.NAME,"email")
    telephone_locator = (By.NAME,"telephone")
    address_locator = (By.NAME,"address")
    submit_locator = (By.NAME,"submit")
    brand_locator = (By.CLASS_NAME,"brand")


    def file_upload(self,file):
        self.find_element(self.file_upload_locator).send_keys(file)
        # self.driver.find_element(*self.file_upload_locator).send_keys(file)

    def input_username(self,username):
        self.find_element(self.username_locator).clear()
        self.find_element(self.username_locator).send_keys(username)

    def input_password(self,password):
        self.find_element(self.password_locator).send_keys(password)

    def category_select(self):
        category_element = self.find_element(self.category_locator)
        return Select(category_element)

    def department_select(self):
        department_element = self.find_element(self.department_locator)
        return Select(department_element)

    def role_select(self):
        role_element = self.find_element(self.role_locator)
        return Select(role_element)

    def click_sex(self):
        self.find_element(self.sex_locator).click()

    def input_email(self,email):
        self.find_element(self.email_locator).clear()
        self.find_element(self.email_locator).send_keys(email)

    def input_telephone(self,telephone):
        self.find_element(self.telephone_locator).clear()
        self.find_element(self.telephone_locator).send_keys(telephone)

    def input_address(self,address):
        self.find_element(self.address_locator).clear()
        self.find_element(self.address_locator).send_keys(address)

    def click_submit(self):
        self.find_element(self.submit_locator).click()

    def click_brand(self):
        self.find_element(self.brand_locator).click()



